# Contributor: Henrik Riomar <henrik.riomar@gmail.com>
# Maintainer: Henrik Riomar <henrik.riomar@gmail.com>
pkgname=py3-tpm2-pytss
_pkgname=tpm2-pytss
pkgver=2.1.0
pkgrel=1
pkgdesc="Python bindings for TSS"
url="https://github.com/tpm2-software/tpm2-pytss"
arch="all"
license="BSD-2-Clause"
checkdepends="
	py3-pytest-forked
	py3-pytest-xdist
	swtpm
	"
makedepends="
	py3-pkgconfig
	py3-setuptools
	py3-setuptools_scm
	python3-dev
	tpm2-tss-dev
	"
depends="
	py3-asn1crypto
	py3-cparser
	py3-cryptography
	py3-yaml
	python3
	"
subpackages="$pkgname-pyc"
source="https://github.com/tpm2-software/tpm2-pytss/archive/$pkgver/$_pkgname-$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

case "$CARCH" in
	armv7|ppc64le|s390x) options="!check";; # no swtpm package
	*) ;;
esac

build() {
	export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
	python3 setup.py build
}

check() {
	# skip failing test due to a bad assert on neg test case
	PYTHONPATH="$(echo "$builddir"/build/lib.linux-*)" pytest \
		-n"$(nproc)" --forked \
		--exitfirst \
		-k 'not test_ecc_bad_curves' test
}

package() {
	export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
	python3 setup.py install --skip-build --root="$pkgdir"
}

sha512sums="
da6b19be153e039a3a5a3b2f93112cfc6c5c72cec4e58d1fdf51c0535ffc6919ee869fe05329fb5771b940eacd9529761a6f1c3d8fd00eccdb9768990248bea8  tpm2-pytss-2.1.0.tar.gz
"
